<?php
session_start();
include('../classes/UsersManager.class.php');
if (isset($_SESSION['logged'])) {
    $logged = ($_SESSION['logged'] == 1) ? TRUE : FALSE;
} else if (isset($_COOKIE['cookie_id']) && isset($_COOKIE['token'])) {
    $um = new UsersManager();
    $result = $um->check_cookie($_COOKIE['cookie_id'], $_COOKIE['token']);
    if ($result['done']) {
        $_SESSION['logged'] = 1;
        $_SESSION['user'] = $result['username'];
        $logged = TRUE;
    }
}
?>
